package com.atguigu.test;

import com.atguigu.config.MainConfigOfSchedule;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author 张晓
 * @create 2020-11-20 14:27
 */
public class IOCTest_Schedule {

    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Test
    public void test01() throws InterruptedException {
        AnnotationConfigApplicationContext applicationContext =
                new AnnotationConfigApplicationContext(MainConfigOfSchedule.class);
        System.out.println("当前线程的名字：" + Thread.currentThread().getName() + "当前时间：" + sdf.format(new Date(System.currentTimeMillis())));
        Thread.sleep(Integer.MAX_VALUE);
        Object mySchedule = applicationContext.getBean("mySchedule");
        Object bean = applicationContext.getBean("org.springframework.context.annotation.internalScheduledAnnotationProcessor");
        System.out.println(mySchedule);
        System.out.println(bean);
        applicationContext.close();

    }
}
